<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>资产报修</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, user-scalable=no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta name=”apple-mobile-web-app-status-bar-style” content=”default” />
    <meta name=”apple-mobile-web-app-status-bar-style” content=”black” />
    <meta name=”apple-mobile-web-app-status-bar-style” content=”black-translucent” />
    <meta content="telephone=no" name="format-detection">
    <meta content="email=no" name="format-detection">
    <meta name="format-detection" content="telephone=no"/>
    <link href="${s.base}/mobile/css/weui.min.css" rel="stylesheet"/>
    <link href="${s.base}/mobile/css/jquery-weui.min.css" rel="stylesheet">
    <link href="${s.base}/mobile/css/weChat.css" rel="stylesheet" />
    <script type="text/javascript" src="${s.base}/mobile/js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="${s.base}/mobile/js/fontSize.js"></script>
    <script type="text/javascript" src="${s.base}/mobile/js/window_port.js"></script>
</head>
<body class="cyt-body-gray">
<div class="xf-circle-botbtn" onclick="checkToEdit()">去报修</div>
<div class="content-24">
    <!--<div class="weui-pull-to-refresh__layer">-->
        <!--<div class="pull-to-refresh__arrow"></div> &lt;!&ndash; 上下拉动的时候显示的箭头 &ndash;&gt;-->
        <!--<div class="pull-to-refresh__preloader"></div> &lt;!&ndash; 正在刷新的菊花 &ndash;&gt;-->
        <!--<div class="down">下拉刷新</div>&lt;!&ndash; 下拉过程显示的文案 &ndash;&gt;-->
        <!--<div class="up">释放刷新</div>&lt;!&ndash; 下拉超过50px显示的文案 &ndash;&gt;-->
        <!--<div class="refresh">正在刷新...</div>&lt;!&ndash; 正在刷新时显示的文案 &ndash;&gt;-->
    <!--</div>-->
    <div class="repair-list">
        <ul>
            <div class="" id="showView"></div>
        </ul>
    </div>
    <div class="weui-loadmore">
        <i class="weui-loading"></i>
        <span class="weui-loadmore__tips">正在加载</span>
    </div>
    <div class="nodate-ctn" style="display: none">
        <p>
            <img src="${s.base}/mobile/images/nodates.png"><br>
            <span>暂无数据</span>
        </p>
    </div>
</div>
</body>
<script type="text/javascript" src="${s.base}/mobile/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="${s.base}/mobile/js/jquery-weui.js"></script>
<script type="text/javascript" src="${s.base}/mobile/js/fastclick.js"></script>
<script type="text/javascript" src="${s.base}/mobile/js/common.js"></script>
<script type="text/javascript">
    var limit=10;
    var page=0;
    var loading = false;  //状态标记
    $('.weui-loadmore').hide();
    $(".nodate-ctn").css("height", document.body.scrollHeight - 50);

    $(function () {
        FastClick.attach(document.body);
        initData();
        initListener();
    });

    function initData() {
        postData(1);
    }
    function initListener() {

//        //初始化下拉刷新
//        $(document.body).pullToRefresh();
//        $(document.body).on("pull-to-refresh", function () {
//            page = 1;
//            limit = 10;
//            postData(1);
//        });

    $(document.body).infinite().on("infinite", function () {
        if (loading) return;
        loading = true;
        $('.weui-loadmore').show();
        setTimeout(function () {
            page++;
            postData(2);
        }, 1000);
    });
    }

    function postData(flag) {
        if (flag === 1) {
            $(document.body).infinite(100);
        }
        var str ='${token}';
        $.fn.doPost('/phone/asset/assetWarrantyList', {page: page, limit: limit,token:str}, function (result) {
            var content = "";
            if (result.code === 0) {
                if (!result.hasNextPage) {
                    $(document.body).destroyInfinite();
                }
                for (var i = 0; i < result.data.length; i++) {
                    var items = result.data[i];
                    content +='<li onclick="checkToDetail(\'' + items.id + '\',\'' + items.objectId + '\')">';
                    if (items.assetState == "0") {
                        content += '<div class="repair-status bg-color-label-orange">未处理</div>';
                    } else {
                        content += '<div class="repair-status bg-color-label-blue">已处理</div>';
                    }
                    var str1 = items.title + "报修";
                    var str2 =  items.createTime.substring(0, items.createTime.length - 2);
                    content += ' <h1>' + str1 + '</h1>' +
                        ' <div class="line-div"><label>物品类型：</label>' + items.assetType + '</div>' +
                        '<div class="line-div"><label>物品名称：</label>' + items.title + '</div>' +
                        ' <div class="line-div"><label>报修时间：</label>' + str2 + '</div>' +
                        ' </li>';
                }
                if (isBlank(content)) {
                    $('.nodate-ctn').show();
                }else {
                    if (flag === 1) {
                        $("#showView").html(content);
                        $(document.body).pullToRefreshDone();

                    } else if (flag === 2) {
                        loading = false;
                        $(".weui-loadmore").hide();
                        $("#showView").html(content);
                    }
                }

            } else {
                $.toast('获取数据失败', "text");
            }

        });
    }




    function checkToEdit() {
        var str ='${token}';
        var str1='${applyId}';
        window.location.href="/phone/work/assetEdit?token="+str+"&applyId="+str1;
    }
    function checkToDetail(str2,str3) {
        var str ='${token}';
        var str1='${applyId}';
        window.window.location.href="/phone/work/assetDetail?token="+str+"&applyId="+str1+"&id="+str2+"&objectId="+str3;
    }

</script>
</html>
